//
//  HJStatusToolBar.swift
//  Weibo
//
//  Created by 韩佳 on 16/4/21.
//  Copyright © 2016年 ddg. All rights reserved.
//

import UIKit

class HJStatusToolBar: UIView {
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI(){
        //背景色
//        backgroundColor = RandomColor
        //添加控件
        let retweentButton: UIButton = addChildBtn("转发", imgName: "timeline_icon_retweet")
        let commonButton: UIButton = addChildBtn("评论", imgName: "timeline_icon_comment")
        let likeButton: UIButton = addChildBtn("赞", imgName: "timeline_icon_unlike")
        //分割线
        let sp1 = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
        let sp2 = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
        addSubview(sp1)
        addSubview(sp2)
        //约束控件
        retweentButton.snp_makeConstraints { (make) -> Void in
            make.leading.top.bottom.equalTo(self)
            make.width.equalTo(commonButton)
        }
        commonButton.snp_makeConstraints { (make) -> Void in
            make.top.bottom.equalTo(self)
            make.leading.equalTo(retweentButton.snp_trailing)
            make.width.equalTo(likeButton)
        }
        likeButton.snp_makeConstraints { (make) -> Void in
            make.top.trailing.bottom.equalTo(self)
            make.leading.equalTo(commonButton.snp_trailing)
            make.width.equalTo(retweentButton)
        }
        sp1.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(commonButton.snp_leading)
            make.centerY.equalTo(self)
        }
        sp2.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(commonButton.snp_trailing)
            make.centerY.equalTo(self)
        }
    }
    
    func addChildBtn(title:String, imgName:String) ->UIButton {
        let button = UIButton(btnColor: UIColor.darkGrayColor(), fontSize: HJStatueCellToolBarBtnFont)
        button.setImage(UIImage(named: imgName), forState: UIControlState.Normal)
        button.setTitle(title, forState: UIControlState.Normal)
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background_highlighted"), forState: UIControlState.Highlighted)
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background"), forState: UIControlState.Normal)
        //添加到superView
        addSubview(button)
        return button
    }
    
}
